<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<script src="../../js/mui.min.js"></script>
		<link href="../../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="../css/login.css" />
		<link rel="stylesheet" type="text/css" href="../css/nav.css" />
		<script type="text/javascript" charset="utf-8">
			mui.init();
		</script>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<h1 class="mui-title">标题</h1>
		</header>
		<div class="mui-content">
			<form id="login-form" class="mui-input-group">
				<div class="mui-input-row">
					<label>账号</label>
					<input id="username" type="tel" class="mui-input-clear mui-input" placeholder="请输入账号" data-input-clear="2"><span class="mui-icon mui-icon-clear mui-hidden"></span>
				</div>
				<div class="mui-input-row">
					<label>密码</label>
					<input id="password" type="password" class="mui-input-clear mui-input" placeholder="请输入密码" data-input-clear="3"><span class="mui-icon mui-icon-clear mui-hidden"></span>
				</div>
			</form>
			<div class="mui-content-padded">
				<button id="login" class="mui-btn mui-btn-block mui-btn-primary">登录</button>
				<div class="link-area">
					<a id="reg">注册账号</a> <span class="spliter">|</span>
					<a id="forgetPassword">忘记密码</a>
				</div>
			</div>
		</div>
		<script type="text/javascript" src="../js/URL.js"></script>
		<script src="../../js/commons.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/Base64.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/URL.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			mui.plusReady(function() {
				//沉浸式
				CommonsFunction.setHeaderBackground();
				//登录帐号
				document.getElementById('login').addEventListener('tap', function() {
					//获取帐号
					var username = document.getElementById('username').value;
					//获取密码
					var password = document.getElementById('password').value;
					if(username.length == 0) {
						plus.nativeUI.toast('请输入帐号');
					}
					if(password.length == 0) {
						plus.nativeUI.toast('请输入密码');
					}
					var usernamePassword = username + ":" + password;
					var validate = BASE64.encode(usernamePassword); //编码
					var wt = plus.nativeUI.showWaiting('登录中');
					mui.ajax(API.MGR.LOGIN, {
						data: {
							username: username,
							password: password
						},
						dataType: 'json', //服务器返回json格式数据
						type: 'post', //HTTP请求类型
						timeout: 10000, //超时时间设置为10秒；
						headers: {},
						success: function(data) {
							localStorage.setItem('validate', validate);
							wt.close();
							mui.back();
						},
						error: function(xhr, type, errorThrown) {
							wt.close();
							plus.nativeUI.toast('服务器繁忙');
						}
					});
				});
			});
			//注册帐号
			/*document.getElementById('reg').addEventListener('tap', function() {
				mui.openWindow({
					url: 'loginUser.html',
					id: 'loginUser',
					extras: {},
				})
			});*/
		</script>
	</body>

</html>